//
//  PHBarButtonItem.swift
//  PHWeibo
//
//  Created by 潘荟 on 16/7/19.
//  Copyright © 2016年 BAT. All rights reserved.
//

import UIKit

class PHBarButtonItem: UIBarButtonItem {
    
    init(title:String? = nil,imgName:String? = nil,target: AnyObject?, action: Selector) {
        super.init()
        
        let btn = UIButton()
        
        if let tit = title {
            btn.setTitle(tit, forState: UIControlState.Normal)
            btn.setTitleColor(themeColor, forState: UIControlState.Normal)
            btn.titleLabel?.font = UIFont.systemFontOfSize(15)
        }
        
        if let img = imgName {
            btn.setImage(UIImage(named: img), forState: UIControlState.Normal)
        }
        
        btn.sizeToFit()
        
        btn.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
        
        self.customView = btn
    }
    
    
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

}
